v2ray installation
install v2ray
wget https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
chmod 755 install-release.sh
./install-release.sh
install geoip.dat, geosite.dat
wget https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh
chmod 755 install-dat-release.sh
./install-dat-release.sh
remove v2ray
bash install-release.sh --remove
v2fly/v2ray-examples
--configuration examples, not so useful, document is too short.
debug v2ray
systemctl restart v2ray
systemctl status -l v2ray
systemctl daemon-reload
journalctl -u v2ray --check detailed v2ray log
vim /var/log/v2ray/error.log
v2ray -test -config /usr/local/etc/v2ray/config.json --test configuration.
systemctl enable v2ray --after make sure it works correctly
v2ray configuration
Best combination is websocket + (TLS + Nginx), websocket is reverse proxied by Nginx through TLS. Encryption is done by Nginx.
websocket+TLS+Nginx configuration exmaple
Three configurations files:
/etc/nginx/sites-available/default
/usr/local/etc/v2ray/config.json
client config.json
Only for running TLS thought v2ray itself. E.g. websocket + TLS
v2ray.service use nobody to run by default.
方案三(Certbot)
这里假定你已经通过 Certbot 获取了证书文档。
/etc/letsencrypt/live/example.com/fullchain.pem。
/etc/letsencrypt/live/example.com/privkey.pem。
如果你使用 Debian 发行版,在安装 Cerbot 后,renew 是会定期运行的。
创建 V2Ray 专用的证书文档目录:
install -d -o nobody -g nogroup /etc/ssl/v2ray/
将证书文档以指定权限部署到指定路径:
install -m 644 -o nobody -g nogroup /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/
install -m 600 -o nobody -g nogroup /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/v2ray/
为在后续 renew 中自动重新部署,需要一个脚本,以下是参照内容:
vim /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh
#!/bin/bash
V2RAY_DOMAIN='example.com'
if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$V2RAY_DOMAIN" ]]; then
install -m 644 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/fullchain.pem" -t /etc/ssl/v2ray/
install -m 600 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/privkey.pem" -t /etc/ssl/v2ray/
sleep "$((RANDOM % 2048))"
systemctl restart v2ray.service
fi
给予脚本可运行权限
chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh
重新部署证书后,会自动运行deploy下具有可运行权限的脚本。
Nginx debug
调试代码如下:
sudo systemctl start nginx.service //开启 Nginx
sudo systemctl stop nginx.service //停止 Nginx
sudo systemctl status -l nginx.service //查看 Nginx运行状态
sudo systemctl restart nginx.service //重新启动 Nginx
sudo systemctl disable nginx.service //取消开机启动 Nginx
sudo systemctl reload nginx.service //重载Nginx (如更改Nginx配置需要重新载入数据)
sudo systemctl enable nginx.service //开机启动
调试代码如下: Nginx调试也可以不需要代码后面添加 .service 请先sudo systemctl start nginx.service
和sudo systemctl enable nginx.service
然后在通过下面代码也可以调试.
sudo systemctl start nginx //开启 Nginx
sudo systemctl stop nginx //停止 Nginx
sudo systemctl status -l nginx //查看 Nginx运行状态
sudo systemctl restart nginx //重新启动 Nginx
sudo systemctl disable nginx //取消开机启动 Nginx
sudo systemctl reload nginx //重载Nginx (如更改Nginx配置需要重新载入数据)
sudo systemctl enable nginx //开机启动
nginx -t //test configuration file.
Nginx log:
/var/log/nginx/access.log, /var/log/nginx/error.log.
x2ray安装
Install & Upgrade Xray-core and geodata with User=nobody, but will NOT overwrite User in existing service files
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
Update geoip.dat and geosite.dat only
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install-geodata
Remove Xray, except json and logs
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove
Install & Upgrade Xray-core and geodata with User=root, which will overwrite User in existing service files
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
Install & Upgrade Xray-core without geodata
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install --without-geodata
Remove Xray, include json and logs
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge